<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<script language="JavaScript"> 
function s_month_chanhe(obj){
	var s_month = obj.value; // 선택 월
	var s_year  = document.getElementById('s_year').value; //년 콤보박스
	var s_day_obj  = document.getElementById('s_day'); // 날짜 콤보박스
	var oMaxDay = new Date(new Date(s_year, s_month, 1)-86400000).getDate(); // 해당월의 마지막 날짜 구하기
	
	removeAll(s_day_obj); // 전체 options 삭제
	set_day_option(s_day_obj,oMaxDay); // 해당 마지막 날짜까지 options 생성
}

function e_month_chanhe(obj1){
	var e_month = obj1.value; // 선택 월
	var e_year  = document.getElementById('e_year').value; // 년 콤보박스
	var e_day_obj  = document.getElementById('e_day'); // 날짜 콤보박스
	var oMaxDay = new Date(new Date(e_year, e_month, 1)-86400000).getDate(); // 해당월의 마지막 날짜 구하기

	removeAll1(e_day_obj); // 전체 options 삭제
	set_day_option1(e_day_obj,oMaxDay); // 해당 마지막 날짜까지 options 생성
}

function removeAll(e){
	var limit = e.options.length;
	for(var i = limit; i >=0 ; i--){
		e.remove(i);
	}
}

function set_day_option(obj, max_len){
	for(var i = 1; i <=max_len ; i++){
		var opt = document.createElement("option");
		opt.value = i;
		opt.text = i;
		obj.options.add(opt);
	}
}

function removeAll1(e){
	var limit = e.options.length;
	for(var i = limit; i >=0 ; i--){
		e.remove(i);
	}
}

function set_day_option1(obj, max_len){
	for(var i = 1; i <=max_len ; i++){
		var opt = document.createElement("option");
		opt.value = i;
		opt.text = i;
		obj.options.add(opt);
	}
}

function checkIt() {
	var f = document.company;
	var ischecked = null;
	for(i=0; i<f.kind.length; i++) {
		if(f.kind[i].checked) {
            ischecked = true;
            break;
        }
	}
	if(!f.name.value)
       {
           alert("이름을 등록하세요");
           return false;
       }
	if(!f.email.value)
       {
           alert("이메일을 등록하세요");
           return false;
       }
	if(ischecked) {
			f.submit();
	}
	else {
		alert("분야를 선택하세요" + f.kind.value);	
		return false;
	}
}
</script>

<form method="post" name="company" action="companyReg.html" onsubmit="return checkIt()">
<div id="main" class="site-main">
	<div class="full-container">		
<div id="primary" class="content-area">
	<div id="content" class="site-content">
		<div class="entry-content">
		<center>		

			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
				<h1><b>회사명</b></h1><br><br>
					<input type=text name="name">
				</div>
			</div>
			<br>
			<hr>
			
			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
				<h1><b>모집기간</b></h1><br><br>
	  
	  <!-- 시작 날짜 -->
	  시작일 : 
	  <select name="s_year" id="s_year" title="년">
      <option value="2014">2014</option>
      </select>년&nbsp;
      <select name="s_month" id="s_month" title="월" onChange="s_month_chanhe(this);">
             <c:forEach var="m" begin="1" end="12" step="1">
             	<option value="${m }">${m }</option>
             </c:forEach>
      </select>월&nbsp;
      <select name="s_day" id="s_day" title="일"></select>일&nbsp;<br><br>
	  
	  <!-- 종료 날짜 -->
	  종료일 : 
	  <select name="e_year" id="e_year" title="년">
      <option value="2014">2014</option>
      </select>년&nbsp;
      <select name="e_month" id="e_month" title="월" onChange="e_month_chanhe(this);">
             <c:forEach var="m" begin="1" end="12" step="1">
             	<option value="${m }">${m }</option>
             </c:forEach>
      </select>월&nbsp;
      <select name="e_day" id="e_day" title="일"></select>일&nbsp;
				</div>
			</div>
			<br>
			<hr>
			
			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
				<h1><b>지원 이메일</b></h1><br><br>
					<input type=text name="email">
				</div>
			</div>
			<br>
			<hr>
			
			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
				<h1><b>링크</b></h1><br><br>
					<input type=text name="link">
				</div>
			</div>
			<br>
			<hr>
			
			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
				<h1><b>모집 분야</b></h1><br><br>
					<input type=radio name="kind" value='0'>웹/앱 개발자 &emsp;
					<input type=radio name="kind" value='2'>웹 개발자 &emsp;
   					<input type=radio name="kind" value='3'>앱 개발자 &emsp;
   					<input type=radio name="kind" value='4'>네트워크 관리자 &emsp;
   					<input type=radio name="kind" value='5'>서버 관리자 &emsp;
   					<input type=radio name="kind" value='6'>보안 전문가 &emsp;
   					<input type=radio name="kind" value='7'>DB 관리자
				</div>
			</div>
			<br>
			<hr>
			<div class="panel-grid" id="pg-home-0">
				<div class="text" id="content">
					<input type=submit value="등록">&emsp;<input type=reset value="취소">
				</div>
			</div>
		</center>
		</div>
	</div>
</div>
	</div>
</div>
</form>
